import { PublicInterface } from '@/interface/public';

/**
 * @description: 使用本地条件查询
 * @return {*}
 */
export const useLocaLitySearch = () => {
  let originData = ref<any>([]);
  const search = (proTableBox: PublicInterface.ProTableValue, params: any) => {
    if (proTableBox.value) {
      proTableBox.value.originData = originData.value.filter((item: any) => {
        // 使用Object.entries遍历查询条件的键值对
        return Object.entries(params).every(([key, value]) => {
          return !value || item[key].trim() === value;
        });
      });
    }
  };
  return {
    search,
    originData
  };
};
